package com.iyunsir.user.entity;

import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.util.Date;

@Data

public class User {
    private Integer id;
    private String username;
    private String password;
    private String chName;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    private Integer roleId;

    public void encodePassword() {
        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
        this.password = passwordEncoder.encode(this.password);
    }
}
